package com.ccom.ccomstart;

import com.ccom.ccomstart.controller.HelloController;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;

/**
 * @Description:
 * @auther: jjzhang24
 * @date: 2021年12月13日
 */
@RunWith(SpringRunner.class)
@WebMvcTest(controllers = HelloController.class)
public class ControllerTest2 {

    @Autowired
    public MockMvc mockMvc;

    @Test
    public void test2() throws Exception {
        System.out.println("q11");
        mockMvc.perform(MockMvcRequestBuilders.get("/hello/test")).andExpect(MockMvcResultMatchers.status().isOk());
        mockMvc.perform(MockMvcRequestBuilders.get("/hello/test")).andExpect(MockMvcResultMatchers.status().isOk()).andExpect(MockMvcResultMatchers.content().string("hello test"));
    }
}
